import { request } from '@/http/axios';

export interface IBase {
  createBy: string;
  createTime: Date;
  updateBy: string;
  updateTime: Date;
}

export interface IRecords<T = any> {
  pageNum: number;
  pageSize: number;
  pages: number;
  total: number;
  list: T[]
}

export interface IPagination {
  pageNum: number;
  pageSize: number;
  total: number;
}

export interface ILogin {
  username: string;
  password: string;
}

function login(data) {
  return request({
    method: 'POST',
    url: '/sys/user/login',
    data
  });
}

function upload(file) {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    method: 'POST',
    url: '/upload',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: formData
  });
}

function getUserInfo() {
  return request({
    url: '/sys/user/getUserInfo',
    method: 'POST'
  });
}

export const appModel = {
  login,
  upload,
  getUserInfo
};
